﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WSManager.Wpf.ArticleEditor
{
    /// <summary>
    /// Interaction logic for NewArticle.xaml
    /// </summary>
    public partial class ArticleEditor: Window
    {
        public ArticleEditor()
        {
            InitializeComponent();
            Closing += ArticleEditor_Closing;
        }

        void ArticleEditor_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (ArticleEditorManager.IsRegistered(viewModel))
                if (MessageBox.Show("Save Changes?", "Save Changes?", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    ArticleEditorManager.SaveArticle(viewModel);
                }
                else
                {
                    ArticleEditorManager.DeregisterEditorVm(viewModel);
                }
            

        }
    }
}
